﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public DataSet QueryHRSTAMM(DataRow dwData, int option = 1)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // GSCMANDANT GSCART GSCVAR GSCFARBE


            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM HRSTAMM WHERE  ROWNUM<2 ";
                    break;
                case 1:
                    or1.CommandText = "SELECT * FROM HRSTAMM WHERE HRMANDANT=:HRMANDANT AND HRBENID=:HRBENID AND HRDFAX=:HRDFAX";
                    or1.Parameters.Add("HRMANDANT", OracleType.NVarChar).Value = dwData["HRMANDANT"].ToString();
                    or1.Parameters.Add("HRBENID", OracleType.NVarChar).Value = dwData["HRBENID"].ToString();
                    or1.Parameters.Add("HRDFAX", OracleType.NVarChar).Value = dwData["HRDFAX"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM HRSTAMM WHERE HRMANDANT=:HRMANDANT AND HRBENID=:HRBENID";
                    or1.Parameters.Add("HRMANDANT", OracleType.NVarChar).Value = dwData["HRMANDANT"].ToString();
                    or1.Parameters.Add("HRBENID", OracleType.NVarChar).Value = dwData["HRBENID"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT HRBENID,HRVNAME,HRNNAME FROM HRSTAMM";
                    break;

                case 4:
                    or1.CommandText = "SELECT HRBENID,HRVNAME,HRNNAME FROM HRSTAMM WHERE HRMANDANT=:HRMANDANT ";
                    or1.Parameters.Add("HRMANDANT", OracleType.NVarChar).Value = dwData["HRMANDANT"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT HRDTELD,HRFILLER,DB11 FROM HRSTAMM H "
                    + " LEFT JOIN (SELECT ITPMANDANT, COUNT(*) AS DB11 FROM ITPRS GROUP BY ITPMANDANT ) Y"
                    + " ON ITPMANDANT=HRMANDANT"
                    + " WHERE   HRMANDANT=:HRMANDANT AND HRBENID ='INTEX   '";
                    or1.Parameters.Add("HRMANDANT", OracleType.NVarChar).Value = dwData["HRMANDANT"].ToString(); 
                    break; 
                default:
                    break;
            }
            SResult = Connect2Proxy(or1);
            if (SResult.Tables.Count > 0)
            {
                tbLocal = SResult.Tables[0];
                tbLocal.TableName = "HRSTAMM";
            }
            SReturn.Merge(SResult);
            return SReturn;
        }
    }
}
